export function count(arr: any[]){
    return arr.length
}

function value(value: any){
    if(typeof value === 'function'){
        return value()
    }
    return value
}

export function get(arr: any, key: string | number, def = null){
    if(typeof key === 'number') return arr[key]
    
    let val = arr
    for(let segment of key.split('.')){
        if(val[segment]){
            val = val[segment]
        } else {
            return value(def)
        }
    }
    return val
}